import { useMenuStore } from "@/store/menu";
import router from "@/router";
/**
 * 显示隐藏tab
 * @param {Array} value
 * @returns {Boolean}
 * @example see @/views/orderManage/RedPacketMallOrderInfo.vue
 */
export default function checkPermission(value: string) {
  if (value && !Array.isArray(value)) {
    // const permissionInfo = store.getters && store.getters.permissionInfo;
    const permissionInfo = useMenuStore().permissionInfo;
    // const permissionRoles = value;

    const hasPermission = permissionInfo[router.currentRoute.value.name as string].includes(value);

    // if (permissionInfo["w_" + router.currentRoute.name] === undefined) return false;

    // const hasPermission = permissionInfo["w_" + router.currentRoute.name].includes(permissionRoles);
    return hasPermission;
  } else {
    console.error(`v-if="checkPermission('getOrderPrint')"`);
    return false;
  }
}
